package com.wr.utils;

import com.wr.annotation.Autowired;
import com.wr.annotation.Component;

/**
 * @author 王瑞
 * @descreption:
 * @date 2020/2/16  12:23
 */
@Component
public class TransationManager {

    @Autowired
    private ConnectionUtil connectionUtil;

    public void setConnectionUtil(ConnectionUtil connectionUtil) {
        this.connectionUtil = connectionUtil;
    }


    public void startTransation() throws Exception {
        connectionUtil.getConnection().setAutoCommit(false);
    }

    public void commitTransation() throws Exception {
        connectionUtil.getConnection().commit();
    }

    public void rollbackTransation() throws Exception {
        connectionUtil.getConnection().rollback();
    }

}
